﻿namespace Agent
{
    using System;
    using System.CodeDom.Compiler;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.IO;
    using System.Runtime.CompilerServices;
    using System.Threading;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Input;
    using System.Windows.Markup;
    using System.Windows.Media.Imaging;
    using TheSafety.Dialogs;

    [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
    public class SubscriptionItem : UserControl, IComponentConnector
    {
        private EventHandler<MouseButtonEventArgs> a;
        private EventHandler<MouseButtonEventArgs> b;
        private EventHandler<MouseButtonEventArgs> c;
        internal ContextMenu d;
        internal MenuItem e;
        internal Image f;
        internal Label g;
        internal Label h;
        internal Label i;
        internal Label j;
        internal Label k;
        internal Image l;
        internal Image m;
        internal Image n;
        private bool o;
        [CompilerGenerated]
        private string p;
        [CompilerGenerated]
        private string q;
        [CompilerGenerated]
        private string r;
        [CompilerGenerated]
        private string s;
        [CompilerGenerated]
        private string t;
        [CompilerGenerated]
        private string u;
        [CompilerGenerated]
        private string v;
        [CompilerGenerated]
        private string w;

        public SubscriptionItem()
        {
            this.InitializeComponent();
            this.a();
        }

        private void a()
        {
            this.i.Content = e.c("ActiveFor");
            this.e.Header = e.c("ChangePassword");
            this.l.ToolTip = e.c("ProlongSubscription");
            this.n.ToolTip = e.c("CancelSubscription");
            this.m.ToolTip = e.c("ChangeSubscription");
        }

        public void a(EventHandler<MouseButtonEventArgs> A_0)
        {
            EventHandler<MouseButtonEventArgs> handler2;
            EventHandler<MouseButtonEventArgs> a = this.a;
            do
            {
                handler2 = a;
                EventHandler<MouseButtonEventArgs> handler3 = (EventHandler<MouseButtonEventArgs>) Delegate.Remove(handler2, A_0);
                a = Interlocked.CompareExchange<EventHandler<MouseButtonEventArgs>>(ref this.a, handler3, handler2);
            }
            while (a != handler2);
        }

        private string a(DateTime A_0)
        {
            TimeSpan span = A_0.Subtract(DateTime.Now.ToUniversalTime());
            return string.Concat(new object[] { span.Days, e.c("d"), " ", span.Hours, e.c("h"), " ", span.Minutes, e.c("m") });
        }

        private DateTime a(string A_0)
        {
            double result = 0.0;
            double.TryParse(A_0, out result);
            DateTime time = new DateTime(0x7b2, 1, 1, 0, 0, 0);
            return time.AddSeconds(result);
        }

        [EditorBrowsable(EditorBrowsableState.Never), DebuggerNonUserCode]
        private void a(int A_0, object A_1)
        {
            switch (A_0)
            {
                case 1:
                    ((SubscriptionItem) A_1).Loaded += new RoutedEventHandler(this.UserControl_Loaded);
                    ((SubscriptionItem) A_1).MouseEnter += new MouseEventHandler(this.UserControl_MouseEnter);
                    ((SubscriptionItem) A_1).MouseLeave += new MouseEventHandler(this.UserControl_MouseLeave);
                    return;

                case 2:
                    this.d = (ContextMenu) A_1;
                    return;

                case 3:
                    this.e = (MenuItem) A_1;
                    this.e.Click += new RoutedEventHandler(this.itmChangePass_Click);
                    return;

                case 4:
                    this.f = (Image) A_1;
                    return;

                case 5:
                    this.g = (Label) A_1;
                    return;

                case 6:
                    this.h = (Label) A_1;
                    return;

                case 7:
                    this.i = (Label) A_1;
                    return;

                case 8:
                    this.j = (Label) A_1;
                    return;

                case 9:
                    this.k = (Label) A_1;
                    return;

                case 10:
                    this.l = (Image) A_1;
                    this.l.MouseLeftButtonUp += new MouseButtonEventHandler(this.imgStrelka_MouseLeftButtonUp);
                    this.l.MouseEnter += new MouseEventHandler(this.imgStrelka_MouseEnter);
                    this.l.MouseLeave += new MouseEventHandler(this.imgStrelka_MouseLeave);
                    return;

                case 11:
                    this.m = (Image) A_1;
                    this.m.MouseLeftButtonUp += new MouseButtonEventHandler(this.imgShesternya_MouseLeftButtonUp);
                    this.m.MouseEnter += new MouseEventHandler(this.imgShesternya_MouseEnter);
                    this.m.MouseLeave += new MouseEventHandler(this.imgShesternya_MouseLeave);
                    return;

                case 12:
                    this.n = (Image) A_1;
                    this.n.MouseLeftButtonUp += new MouseButtonEventHandler(this.imgIks_MouseLeftButtonUp);
                    this.n.MouseEnter += new MouseEventHandler(this.imgIks_MouseEnter);
                    this.n.MouseLeave += new MouseEventHandler(this.imgIks_MouseLeave);
                    return;
            }
            this.o = true;
        }

        public void b(EventHandler<MouseButtonEventArgs> A_0)
        {
            EventHandler<MouseButtonEventArgs> handler2;
            EventHandler<MouseButtonEventArgs> c = this.c;
            do
            {
                handler2 = c;
                EventHandler<MouseButtonEventArgs> handler3 = (EventHandler<MouseButtonEventArgs>) Delegate.Remove(handler2, A_0);
                c = Interlocked.CompareExchange<EventHandler<MouseButtonEventArgs>>(ref this.c, handler3, handler2);
            }
            while (c != handler2);
        }

        public void c(EventHandler<MouseButtonEventArgs> A_0)
        {
            EventHandler<MouseButtonEventArgs> handler2;
            EventHandler<MouseButtonEventArgs> a = this.a;
            do
            {
                handler2 = a;
                EventHandler<MouseButtonEventArgs> handler3 = (EventHandler<MouseButtonEventArgs>) Delegate.Combine(handler2, A_0);
                a = Interlocked.CompareExchange<EventHandler<MouseButtonEventArgs>>(ref this.a, handler3, handler2);
            }
            while (a != handler2);
        }

        public void d(EventHandler<MouseButtonEventArgs> A_0)
        {
            EventHandler<MouseButtonEventArgs> handler2;
            EventHandler<MouseButtonEventArgs> b = this.b;
            do
            {
                handler2 = b;
                EventHandler<MouseButtonEventArgs> handler3 = (EventHandler<MouseButtonEventArgs>) Delegate.Remove(handler2, A_0);
                b = Interlocked.CompareExchange<EventHandler<MouseButtonEventArgs>>(ref this.b, handler3, handler2);
            }
            while (b != handler2);
        }

        public void e(EventHandler<MouseButtonEventArgs> A_0)
        {
            EventHandler<MouseButtonEventArgs> handler2;
            EventHandler<MouseButtonEventArgs> b = this.b;
            do
            {
                handler2 = b;
                EventHandler<MouseButtonEventArgs> handler3 = (EventHandler<MouseButtonEventArgs>) Delegate.Combine(handler2, A_0);
                b = Interlocked.CompareExchange<EventHandler<MouseButtonEventArgs>>(ref this.b, handler3, handler2);
            }
            while (b != handler2);
        }

        public void f(EventHandler<MouseButtonEventArgs> A_0)
        {
            EventHandler<MouseButtonEventArgs> handler2;
            EventHandler<MouseButtonEventArgs> c = this.c;
            do
            {
                handler2 = c;
                EventHandler<MouseButtonEventArgs> handler3 = (EventHandler<MouseButtonEventArgs>) Delegate.Combine(handler2, A_0);
                c = Interlocked.CompareExchange<EventHandler<MouseButtonEventArgs>>(ref this.c, handler3, handler2);
            }
            while (c != handler2);
        }

        private void imgIks_MouseEnter(object A_0, MouseEventArgs A_1)
        {
            this.n.Source = new BitmapImage(new Uri("pack://application:,,,/thesafety;component/Resources/3.png"));
        }

        private void imgIks_MouseLeave(object A_0, MouseEventArgs A_1)
        {
            this.n.Source = new BitmapImage(new Uri("pack://application:,,,/thesafety;component/Resources/6.png"));
        }

        private void imgIks_MouseLeftButtonUp(object A_0, MouseButtonEventArgs A_1)
        {
            if (this.b != null)
            {
                this.b(this, A_1);
            }
        }

        private void imgShesternya_MouseEnter(object A_0, MouseEventArgs A_1)
        {
            this.m.Source = new BitmapImage(new Uri("pack://application:,,,/thesafety;component/Resources/2.png"));
        }

        private void imgShesternya_MouseLeave(object A_0, MouseEventArgs A_1)
        {
            this.m.Source = new BitmapImage(new Uri("pack://application:,,,/thesafety;component/Resources/5.png"));
        }

        private void imgShesternya_MouseLeftButtonUp(object A_0, MouseButtonEventArgs A_1)
        {
            if (this.c != null)
            {
                this.c(this, A_1);
            }
        }

        private void imgStrelka_MouseEnter(object A_0, MouseEventArgs A_1)
        {
            this.l.Source = new BitmapImage(new Uri("pack://application:,,,/thesafety;component/Resources/1.png"));
        }

        private void imgStrelka_MouseLeave(object A_0, MouseEventArgs A_1)
        {
            this.l.Source = new BitmapImage(new Uri("pack://application:,,,/thesafety;component/Resources/4.png"));
        }

        private void imgStrelka_MouseLeftButtonUp(object A_0, MouseButtonEventArgs A_1)
        {
            if (this.a != null)
            {
                this.a(this, A_1);
            }
        }

        [DebuggerNonUserCode]
        public void InitializeComponent()
        {
            if (!this.o)
            {
                this.o = true;
                Uri resourceLocator = new Uri("/TheSafety;component/management/subscriptionitem.xaml", UriKind.Relative);
                Application.LoadComponent(this, resourceLocator);
            }
        }

        private void itmChangePass_Click(object A_0, RoutedEventArgs A_1)
        {
            ChangePasswordVPN dvpn = new ChangePasswordVPN();
            dvpn.a(this.f());
            dvpn.ShowDialog();
        }

        private void UserControl_Loaded(object A_0, RoutedEventArgs A_1)
        {
            if (this.f() == "Account Type")
            {
                this.g.Content = e.c("GUILicense");
                this.h.Content = this.e();
                this.m.IsEnabled = false;
                if (AgentUser.a().b() == LicenseType.Elite)
                {
                    this.f.Source = new BitmapImage(new Uri("pack://application:,,,/thesafety;component/Resources/license_premium.png"));
                }
                else
                {
                    this.f.Source = new BitmapImage(new Uri("pack://application:,,,/thesafety;component/Resources/license_limited.png"));
                }
                this.d.Visibility = Visibility.Collapsed;
            }
            else
            {
                if (this.e().Length > 20)
                {
                    this.g.Content = this.e().Substring(0, 20) + " ...";
                }
                else
                {
                    this.g.Content = this.e();
                }
                this.h.Content = e.c("VPNUsername") + ": " + this.f();
                if (!string.IsNullOrWhiteSpace(this.b()))
                {
                    try
                    {
                        if (File.Exists(ConfigManager.q() + "/config/" + this.b() + ".png"))
                        {
                            this.f.Source = new BitmapImage(new Uri(ConfigManager.q() + "/config/" + this.b() + ".png"));
                        }
                        else
                        {
                            this.f.Source = new BitmapImage(new Uri("pack://application:,,,/thesafety;component/Resources/ip.png"));
                        }
                    }
                    catch (Exception exception)
                    {
                        ConfigManager.a("UserControl_Loaded", exception);
                    }
                }
            }
            this.j.Content = this.a(this.h()).ToShortDateString();
            this.k.Content = "(" + this.a(this.a(this.h())) + ")";
            if (this.g().ToLower().Trim() == "0")
            {
                this.n.IsEnabled = false;
                this.m.IsEnabled = false;
                this.k.Content = e.c("Expired");
                this.i.Content = e.c("NotActive");
                this.j.Content = string.Empty;
                this.d.IsEnabled = false;
            }
        }

        private void UserControl_MouseEnter(object A_0, MouseEventArgs A_1)
        {
            if (this.f() != "Account Type")
            {
                this.m.Visibility = Visibility.Visible;
                this.n.Visibility = Visibility.Visible;
            }
            this.l.Visibility = Visibility.Visible;
            this.k.Visibility = Visibility.Hidden;
            if (this.c().ToLower().Trim() == "1")
            {
                this.m.Visibility = Visibility.Hidden;
            }
        }

        private void UserControl_MouseLeave(object A_0, MouseEventArgs A_1)
        {
            this.n.Visibility = Visibility.Hidden;
            this.m.Visibility = Visibility.Hidden;
            this.l.Visibility = Visibility.Hidden;
            this.k.Visibility = Visibility.Visible;
        }

        public string SubscribtionDate
        {
            [CompilerGenerated]
            get
            {
                return this.s;
            }
            [CompilerGenerated]
            set
            {
                this.s = value;
            }
        }

        public string SubscribtionDedIP
        {
            [CompilerGenerated]
            get
            {
                return this.u;
            }
            [CompilerGenerated]
            set
            {
                this.u = value;
            }
        }

        public string SubscribtionID
        {
            [CompilerGenerated]
            get
            {
                return this.p;
            }
            [CompilerGenerated]
            set
            {
                this.p = value;
            }
        }

        public string SubscribtionImgName
        {
            [CompilerGenerated]
            get
            {
                return this.v;
            }
            [CompilerGenerated]
            set
            {
                this.v = value;
            }
        }

        public string SubscribtionIsActive
        {
            [CompilerGenerated]
            get
            {
                return this.w;
            }
            [CompilerGenerated]
            set
            {
                this.w = value;
            }
        }

        public string SubscribtionLogin
        {
            [CompilerGenerated]
            get
            {
                return this.r;
            }
            [CompilerGenerated]
            set
            {
                this.r = value;
            }
        }

        public string SubscribtionName
        {
            [CompilerGenerated]
            get
            {
                return this.q;
            }
            [CompilerGenerated]
            set
            {
                this.q = value;
            }
        }

        public string SubscribtionWhile
        {
            [CompilerGenerated]
            get
            {
                return this.t;
            }
            [CompilerGenerated]
            set
            {
                this.t = value;
            }
        }
    }
}

